﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smartec.Accounts.Camel.AMS.Model.Entities;

namespace Smartec.Accounts.Camel.AMS.Model.Repository
{
    internal static class SiteUserRepository
    {

        //
        // Query Methods

        public static IEnumerable<SiteUser> FindAllSiteUsers()
        {
            return AMSObjectContextHelper.CurrentObjectContext.SiteUsers
                 .AsEnumerable()
                .Select(o => new SiteUser { ID = o.ID,  DisplayName_EN = o.DisplayName_EN, DisplayName_AR = o.DisplayName_AR, IsActive = o.IsActive, StartDate = o.StartDate, EndDate = o.EndDate });
        }

        public static SiteUser GetSiteUser(Guid id)
        {
            return AMSObjectContextHelper.CurrentObjectContext.SiteUsers.SingleOrDefault(d => d.ID == id);
        }

        //
        // Insert/Delete Methods

        public static void Add(SiteUser siteUser)
        {
            AMSObjectContextHelper.CurrentObjectContext.SiteUsers.AddObject(siteUser);

        }

        public static void Delete(SiteUser siteUser)
        {
            AMSObjectContextHelper.CurrentObjectContext.SiteUsers.DeleteObject(siteUser);
        }

        //
        // Persistence 

        public static void Save()
        {
            AMSObjectContextHelper.CurrentObjectContext.SaveChanges();
        }

        // Helper Methods

    }
}
